using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RotationController : MonoBehaviour
{
    public Rigidbody2D ballRigidbody; // 小球的刚体
    public float rotationFactor = 5f; // 旋转的比例因子，调整旋转速度

    private void Awake()
    {
        ballRigidbody = GetComponent<Rigidbody2D>();
    }

    void FixedUpdate()
    {
        // 获取小球的速度
        Vector2 velocity = ballRigidbody.velocity;

        // 计算旋转角度，根据速度调整
        float rotation = -velocity.x * rotationFactor;

        // 应用旋转到小球
        transform.Rotate(0, 0, rotation);
    }
}